/**
  * 大厅
  */
module game {

    export class HallMediator extends BaseMediator {
        public static NAME: string = "HallMediator";
        public constructor(viewComponent: any = null) {
            super(HallMediator.NAME, viewComponent);
        }
        public listNotificationInterests(): Array<any> {
            return [
                PanelNotify.HALL.STAGE_RESIZE,
                PanelNotify.HALL.OPEN_HALL,
                PanelNotify.HALL.CLOSE_HALL,
                PanelNotify.HALL.BACK_HALL_BY_GAME,
                PanelNotify.HALL.FIND_USER_MONEY,
                PanelNotify.HALL.FIND_USER_NAME,
                PanelNotify.HALL.JOIN_GAME_BY_HALL,
                PanelNotify.HALL.REFRESH_ROOM_IFO,
                PanelNotify.HALL.REFRESH_USER_INFO,
                PanelNotify.HALL.HEID_MAIL_TIP,
            ];
        }
        private interval: number = 0;
        private panel: HallPanel;
        public static DragonBonesLIST: Array<dragonBones.EgretArmatureDisplay> = [];
        public handleNotification(notification: puremvc.INotification): void {
            switch (notification.getName()) {
                case PanelNotify.HALL.STAGE_RESIZE:
                    if (this.panel) {
                        this.panel.width = GameConfig.curWidth()
                        this.panel.height = GameConfig.curHeight()
                    }
                    break;
                case PanelNotify.HALL.OPEN_HALL:
                    //显示角色面板
                    this.panel = null;
                    this.panel = new HallPanel();
                    this.showUI(this.panel, 2, 1);
                    this.getUserInfo();
                    break;
                case PanelNotify.HALL.CLOSE_HALL:
                    this.closePanel(1);
                    break;
                case PanelNotify.HALL.BACK_HALL_BY_GAME:
                    this.exitGame();
                    this.findUserMoney();
                    // this.findTiXianOpen();//查询提现开放
                    break;
                case PanelNotify.HALL.FIND_USER_MONEY:
                    this.findUserMoney();
                    break;
                case PanelNotify.HALL.FIND_USER_NAME:
                    this.findUserName();
                    break;
                case PanelNotify.HALL.JOIN_GAME_BY_HALL:
                    this.joinGame();
                    break;
                case PanelNotify.HALL.REFRESH_ROOM_IFO:
                    egret.setTimeout(this.refreshRoomList, this, 150)
                    break;
                case PanelNotify.HALL.REFRESH_USER_INFO:
                    this.getUserInfo();
                    break;
                case PanelNotify.HALL.HEID_MAIL_TIP:
                    this.panel.weiduxiaoxi.visible = false;
                    break;
            }
        }

        /**
         * 初始化面板ui
         */
        public initUI(): void {
            if (InstructionsEnum.SOUND_GAME != InstructionsEnum.GAME_SOUND_NAME.HALL) {
                SoundManage.stopYinYue();
                InstructionsEnum.SOUND_GAME = InstructionsEnum.GAME_SOUND_NAME.HALL
                SoundManage.startYinYueLoad();
            }
            //将滚动公告转移到当前面板
            EffectUtils.moveNoticeToPanel(this.panel.noticeGroup)
            this.panel.userIcon.addEventListener(egret.TouchEvent.TOUCH_TAP, this.userIconClick, this);
            this.panel.copyID.addEventListener(egret.TouchEvent.TOUCH_TAP, this.copyIDClick, this);
            this.panel.settingBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onSettingBtnClick, this);
            this.panel.moneyAddBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onAddMoneyBtnClick, this);
            this.panel.moneySxBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.findUserMoney, this);
            this.panel.openRanking.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onOpenRankingBtnClick, this);
            this.panel.openSafeBox.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onOpenSafeBoxBtnClick, this);
            this.panel.huodong.addEventListener(egret.TouchEvent.TOUCH_TAP, this.huoDongClick, this)
            this.panel.kefu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.kefuClick, this)
            this.panel.xiaoxi.addEventListener(egret.TouchEvent.TOUCH_TAP, this.mailClick, this)
            this.panel.daili.addEventListener(egret.TouchEvent.TOUCH_TAP, this.proxyClick, this)
            this.panel.tixian.addEventListener(egret.TouchEvent.TOUCH_TAP, this.TiXianClick, this)

            this.panel.gameList.addEventListener(egret.Event.COMPLETE, () => {
                this.panel.gameList.horizontalScrollBar = null;
                this.panel.gameList.removeEventListener(egret.Event.COMPLETE, () => {
                    this.panel.gameList.horizontalScrollBar = null;
                }, this);
            }, this);
        }
        /**
         * 初始化面板数据
         */
        public initData(): void {
            // this.findTiXianOpen();//查询提现开放
            //登录聊天服务器
            let obj = {
                dwUserID: GameVO.getVo().dwUserID,
                szPassword: GameVO.getVo().szDynamicPass,
                szPhoneMode: "来自PC端H5"
            }
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.CHAT, RegDataChat.CMD_GC_MB_LogonByUserID, obj);

        }
        //个人信息
        private getUserInfo() {
            this.panel.userIcon.source = "special_" + GameVO.getVo().wFaceID % 15;
            this.panel.playerName.text = Global.cutString(GameVO.getVo().szNickName + "", 11, 1);
            this.panel.playerMoney.text = GameVO.getVo().lUserScore / 100 + "";
        }
        //查用户金币
        private findUserMoney() {
            //请求用户信息（刷新金币）
            var request = new egret.HttpRequest();
            request.responseType = egret.HttpResponseType.TEXT;
            request.open(InstructionsEnum.IP_API + "/gameinfo/GetScoreInfo?uid=" + GameVO.getVo().dwUserID + "&isGuest=" + InstructionsEnum.isGuest, egret.HttpMethod.GET);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.addEventListener(egret.Event.COMPLETE, (event: egret.Event) => {
                EffectUtils.hideWaritPanel()
                var request = <egret.HttpRequest>event.currentTarget;
                var obj = JSON.parse(request.response)
                var Score = obj["Score"]
                if (Score) {
                    GameVO.getVo().lUserScore = Number(Score);
                    game.AppFacade.instance.sendNotification(PanelNotify.HALL.REFRESH_USER_INFO)
                }
            }, this);
            request.addEventListener(egret.IOErrorEvent.IO_ERROR, () => {
                EffectUtils.hideWaritPanel()
                Global.tipShow("网络请求失败，请稍后重试!")
            }, this);
            request.send();
            EffectUtils.showWaritPanel()
        }
        //查询用户昵称（个人中心修改资料后利用VIP等级接口查询）
        private findUserName() {
            var time = Math.floor(Global.getCurrTimeLong() / 1000)
            var signature = Global.getSynLoginKey(time)
            signature = signature.toUpperCase()
            var request = new egret.HttpRequest();
            request.responseType = egret.HttpResponseType.TEXT;
            request.open(InstructionsEnum.IP_API + "/PersonalCenter/GetUserInfomation?userid=" + GameVO.getVo().dwUserID + "&signature=" + signature + "&time=" + time, egret.HttpMethod.POST);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.addEventListener(egret.Event.COMPLETE, (event: egret.Event) => {
                try {
                    var request = <egret.HttpRequest>event.currentTarget;
                    var obj = JSON.parse(request.response)
                    if (obj.code == 0) {
                        var data = obj["data"];
                        GameVO.getVo().szNickName = data["UserNickName"];
                        this.getUserInfo();
                    }
                } catch (err) { }
            }, this);
            request.send();
        }
        //查VIP等级
        private findUservipLeve() {
            var time = Math.floor(Global.getCurrTimeLong() / 1000)
            var signature = Global.getSynLoginKey(time)
            signature = signature.toUpperCase()
            var request = new egret.HttpRequest();
            request.responseType = egret.HttpResponseType.TEXT;
            request.open(InstructionsEnum.IP_API + "/PersonalCenter/GetUserInfomation?userid=" + GameVO.getVo().dwUserID + "&signature=" + signature + "&time=" + time, egret.HttpMethod.POST);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.addEventListener(egret.Event.COMPLETE, (event: egret.Event) => {
                try {
                    var request = <egret.HttpRequest>event.currentTarget;
                    var obj = JSON.parse(request.response)
                    if (obj.code == 0) {
                        var data = obj["data"];
                        GameVO.getVo().szNickName = data["UserNickName"];
                        this.getUserInfo();
                        var VIPIndex = data["VIPIndex"];
                        this.panel.vipLevel.visible = true;
                        this.panel.vipLevel.source = "hemo_vip" + VIPIndex
                        this.panel.copyID.y = 8
                        this.panel.playerName.y = 12
                    }
                } catch (err) { }
            }, this);
            var t = egret.setTimeout(() => {
                egret.clearTimeout(t)
                request.send();
            }, this, Math.random() * 1000)
        }
        //查询提款是否开放
        private findTiXianOpen() {
            var time = Math.floor(Global.getCurrTimeLong() / 1000)
            var signature = Global.getSynLoginKey(time)
            signature = signature.toUpperCase()
            var request = new egret.HttpRequest();
            request.responseType = egret.HttpResponseType.TEXT;
            request.open(InstructionsEnum.IP_API + "/GameWebApplication/Api/WithdrawSetting.ashx?userid=" + GameVO.getVo().dwUserID + "&time=" + time + "&signature=" + signature, egret.HttpMethod.POST);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.addEventListener(egret.Event.COMPLETE, (event: egret.Event) => {
                try {
                    var request = <egret.HttpRequest>event.currentTarget;
                    var obj = JSON.parse(request.response)
                    if (obj.code == 0) {
                        if (obj.withdraw_status == 1) {
                            this.panel.tixian.visible = true;
                        } else {
                            this.panel.tixian.visible = false;
                        }
                    }
                } catch (err) { }
            }, this);
            var t = egret.setTimeout(() => {
                egret.clearTimeout(t)
                request.send();
            }, this, Math.random() * 1000)
        }
        //查询未读消息
        private findMail() {
            this.panel.weiduxiaoxi.visible = false;
            var time = Global.getCurrTimeLong()
            var signature = Global.getSynLoginKey(time)
            signature = signature.toUpperCase()
            var request = new egret.HttpRequest();
            request.responseType = egret.HttpResponseType.TEXT;
            request.open(InstructionsEnum.IP_API + "/GameWebApplication/ReadEmail.ashx?userid=" + GameVO.getVo().dwUserID + "&signature=" + signature + "&time=" + time, egret.HttpMethod.POST);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.addEventListener(egret.Event.COMPLETE, (event: egret.Event) => {
                EffectUtils.hideWaritPanel()
                try {
                    var request = <egret.HttpRequest>event.currentTarget;
                    var obj = JSON.parse(request.response)
                    if (obj.code == 0) {
                        var emails: Array<any> = obj["emails"];
                        if (emails) {
                            for (var i = 0; i < emails.length; i++) {
                                if (emails[i]["nStatus"] != 2) {//只要有一条未读消息，就显示小红点提示
                                    this.panel.weiduxiaoxi.visible = true;
                                    return;
                                }
                            }
                        }
                    }
                } catch (err) { }
            }, this);
            request.addEventListener(egret.IOErrorEvent.IO_ERROR, () => {
                EffectUtils.hideWaritPanel()
                Global.tipShow("网络请求失败，请稍后重试!")
            }, this);
            var data = {
                dwUserID: GameVO.getVo().dwUserID
            }
            EffectUtils.showWaritPanel()
            var t = egret.setTimeout(() => {
                egret.clearTimeout(t)
                request.send(JSON.stringify(data));
            }, this, Math.random() * 1000)

        }
        //刷新房间列表
        private refreshRoomList() {
            InstructionsEnum.GAME_SERVER_DATA.DDZ = [];
            InstructionsEnum.GAME_SERVER_DATA.QZNN = [];
            InstructionsEnum.GAME_SERVER_DATA.BRNN = [];
            InstructionsEnum.GAME_SERVER_DATA.HLSZ = [];
            InstructionsEnum.GAME_SERVER_DATA.WJL = [];
            InstructionsEnum.GAME_SERVER_DATA.LHD = [];
            InstructionsEnum.GAME_SERVER_DATA.HHDZ = [];
            InstructionsEnum.GAME_SERVER_DATA.BREBG = [];

            let gameTypeMap = {}//记录已经出现哪些游戏的房间，每种游戏只生成一次骨骼动画按钮
            let roomList = GameVO.getVo().roomList;
            if (Global.isNotEmpty(roomList)) {
                //先隐藏所有游戏按钮
                for (let i = 0; i < this.panel.gamelistGroup.numChildren; i++) {
                    this.panel.gamelistGroup.getChildAt(i).visible = false;
                }
                //后端打开了哪些游戏前端就显示出哪些按钮
                //百人牛牛单独摆在左边
                for (let i = 0; i < roomList.length; i++) {
                    let wKindID = roomList[i].wKindID;//房间类型
                    if (wKindID == 104) {
                        var group = this.panel.game_brdz;
                        var dragonbonesData;
                        var textureData;
                        var texture;
                        var name;
                        dragonbonesData = "ico3n_ske_json"
                        textureData = "ico3n_tex_json"
                        texture = "ico3n_tex"
                        name = "bairenniuniu"
                        const factory = dragonBones.EgretFactory.factory;
                        factory.parseDragonBonesData(RES.getRes(dragonbonesData));
                        factory.parseTextureAtlasData(RES.getRes(textureData), RES.getRes(texture));
                        const armatureDisplay = factory.buildArmatureDisplay(name);
                        armatureDisplay.animation.play();
                        armatureDisplay.alpha = 0;
                        group.addChild(armatureDisplay);
                        egret.Tween.get(armatureDisplay).to({ alpha: 1 }, 800).call(() => {
                            egret.Tween.removeTweens(armatureDisplay)
                        })
                        HallMediator.DragonBonesLIST.push(armatureDisplay)

                        var ske = "caid_ske_json"
                        var json = "caid_tex_json"
                        var tex = "caid_tex"
                        var Armature = "caid"
                        //检查是否最近玩过的游戏
                        var wKindIDArr = egret.localStorage.getItem("wKindID")
                        var arr: Array<any> = []
                        if (wKindIDArr != null) {
                            arr = wKindIDArr.split(",");
                        }
                        if (arr.indexOf(wKindID + "") != -1) {//最近
                            ske = "zj_ske_json"
                            json = "zj_tex_json"
                            tex = "zj_tex"
                            Armature = "zj"
                        }
                        const factory2 = dragonBones.EgretFactory.factory;
                        factory2.parseDragonBonesData(RES.getRes(ske));
                        factory2.parseTextureAtlasData(RES.getRes(json), RES.getRes(tex));
                        const armatureDisplay2 = factory.buildArmatureDisplay(Armature);
                        armatureDisplay2.animation.play();
                        armatureDisplay2.x = 120
                        armatureDisplay2.y = -444
                        armatureDisplay2.alpha = 0;
                        group.addChild(armatureDisplay2);
                        egret.Tween.get(armatureDisplay2).to({ alpha: 1 }, 800).call(() => {
                            egret.Tween.removeTweens(armatureDisplay2)
                        })
                        HallMediator.DragonBonesLIST.push(armatureDisplay2)

                        group.name = InstructionsEnum.GAME_TYPE_NAME.BRNN;
                        group.visible = true;
                        group.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onGame, this);
                        break;
                    }
                }
                for (let i = 0; i < roomList.length; i++) {
                    let wKindID = roomList[i].wKindID;//房间类型
                    if (wKindID == InstructionsEnum.GAME_SERVER_ID.BRNN) {
                        InstructionsEnum.GAME_SERVER_DATA.BRNN.push(roomList[i]);
                    } else if (wKindID == InstructionsEnum.GAME_SERVER_ID.DDZ) {
                        InstructionsEnum.GAME_SERVER_DATA.DDZ.push(roomList[i]);
                        if (gameTypeMap[wKindID] == undefined) {
                            this.showLongGu(InstructionsEnum.GAME_TYPE_NAME.DDZ, wKindID)
                            gameTypeMap[wKindID] = 1;
                        }
                    } else if (wKindID == InstructionsEnum.GAME_SERVER_ID.QZNN) {
                        InstructionsEnum.GAME_SERVER_DATA.QZNN.push(roomList[i]);
                        if (gameTypeMap[wKindID] == undefined) {
                            this.showLongGu(InstructionsEnum.GAME_TYPE_NAME.QZNN, wKindID)
                        }
                        gameTypeMap[wKindID] = 1;
                    } else if (wKindID == InstructionsEnum.GAME_SERVER_ID.HLSZ) {
                        InstructionsEnum.GAME_SERVER_DATA.HLSZ.push(roomList[i]);
                        if (gameTypeMap[wKindID] == undefined) {
                            this.showLongGu(InstructionsEnum.GAME_TYPE_NAME.HLSZ, wKindID)
                        }
                        gameTypeMap[wKindID] = 1;
                    } else if (wKindID == InstructionsEnum.GAME_SERVER_ID.WJL) {
                        InstructionsEnum.GAME_SERVER_DATA.WJL.push(roomList[i]);
                        if (gameTypeMap[wKindID] == undefined) {
                            this.showLongGu(InstructionsEnum.GAME_TYPE_NAME.WJL, wKindID)
                        }
                        gameTypeMap[wKindID] = 1;
                    } else if (wKindID == InstructionsEnum.GAME_SERVER_ID.LHD) {
                        InstructionsEnum.GAME_SERVER_DATA.LHD.push(roomList[i]);
                        if (gameTypeMap[wKindID] == undefined) {
                            this.showLongGu(InstructionsEnum.GAME_TYPE_NAME.LHD, wKindID)
                        }
                        gameTypeMap[wKindID] = 1;
                    } else if (wKindID == InstructionsEnum.GAME_SERVER_ID.HHDZ) {
                        InstructionsEnum.GAME_SERVER_DATA.HHDZ.push(roomList[i]);
                        if (gameTypeMap[wKindID] == undefined) {
                            this.showLongGu(InstructionsEnum.GAME_TYPE_NAME.HHDZ, wKindID)
                        }
                        gameTypeMap[wKindID] = 1;
                    } else if (wKindID == InstructionsEnum.GAME_SERVER_ID.BREBG) {
                        InstructionsEnum.GAME_SERVER_DATA.BREBG.push(roomList[i]);
                        if (gameTypeMap[wKindID] == undefined) {
                            this.showLongGu(InstructionsEnum.GAME_TYPE_NAME.BREBG, wKindID)
                        }
                        gameTypeMap[wKindID] = 1;
                    }
                }
                if (Object.keys(gameTypeMap).length % 2 == 1) {
                    this.panel.game_jjsx.visible = true
                    this.panel.game_jjsx.alpha = 0
                    egret.Tween.get(this.panel.game_jjsx).to({ alpha: 1 }, 800).call(() => {
                        egret.Tween.removeTweens(this.panel.game_jjsx)
                    })
                }
                //没显示出来的游戏删除掉
                let num = this.panel.gamelistGroup.numChildren;
                for (let i = num - 1; i >= 0; i--) {
                    if (this.panel.gamelistGroup.getChildAt(i).visible != true) {
                        this.panel.gamelistGroup.removeChildAt(i)
                    }
                }
            }
        }
        //显示游戏列表龙骨动画
        private showLongGu(gameType: string, wKindID) {
            var group: eui.Group;
            var dragonbonesData;
            var textureData;
            var texture;
            var name;
            if (gameType == InstructionsEnum.GAME_TYPE_NAME.DDZ) {
                dragonbonesData = "ddz_ske_json"
                textureData = "ddz_tex_json"
                texture = "ddz_tex"
                name = "ddz"
                group = this.panel.game_ddz;
            } else if (gameType == InstructionsEnum.GAME_TYPE_NAME.HLSZ) {
                dragonbonesData = "zjh_ske_json"
                textureData = "zjh_tex_json"
                texture = "zjh_tex"
                name = "zjh"
                group = this.panel.game_hlsz;
            } else if (gameType == InstructionsEnum.GAME_TYPE_NAME.QZNN) {
                dragonbonesData = "qznn_ske_json"
                textureData = "qznn_tex_json"
                texture = "qznn_tex"
                name = "qznn"
                group = this.panel.game_qzdz;
            } else if (gameType == InstructionsEnum.GAME_TYPE_NAME.WJL) {
                dragonbonesData = "bjl_ske_json"
                textureData = "bjl_tex_json"
                texture = "bjl_tex"
                name = "bjl"
                group = this.panel.game_wjl;
            } else if (gameType == InstructionsEnum.GAME_TYPE_NAME.LHD) {
                dragonbonesData = "longhu_ske_json"
                textureData = "longhu_tex_json"
                texture = "longhu_tex"
                name = "longhu"
                group = this.panel.game_lzhd;
            } else if (gameType == InstructionsEnum.GAME_TYPE_NAME.HHDZ) {
                dragonbonesData = "hhdz_ske_json"
                textureData = "hhdz_tex_json"
                texture = "hhdz_tex"
                name = "hhdz"
                group = this.panel.game_hhdz;
            } else if (gameType == InstructionsEnum.GAME_TYPE_NAME.BREBG) {
                dragonbonesData = "ebg_ske_json"
                textureData = "ebg_tex_json"
                texture = "ebg_tex"
                name = "ebg"
                group = this.panel.game_brebg;
            }

            const factory = dragonBones.EgretFactory.factory;
            factory.parseDragonBonesData(RES.getRes(dragonbonesData));
            factory.parseTextureAtlasData(RES.getRes(textureData), RES.getRes(texture));
            const armatureDisplay = factory.buildArmatureDisplay(name);
            armatureDisplay.animation.play();
            armatureDisplay.x = 140
            armatureDisplay.y = 270
            armatureDisplay.alpha = 0;
            group.addChild(armatureDisplay);
            egret.Tween.get(armatureDisplay).to({ alpha: 1 }, 800).call(() => {
                egret.Tween.removeTweens(armatureDisplay)
            })
            HallMediator.DragonBonesLIST.push(armatureDisplay)

            //热门 最近 最新 标签
            var newGame = [InstructionsEnum.GAME_SERVER_ID.BREBG]
            var ske = ""
            var json = ""
            var tex = ""
            var Armature = ""
            //检查是否最近玩过的游戏
            var wKindIDArr = egret.localStorage.getItem("wKindID")
            var arr: Array<any> = []
            if (wKindIDArr != null) {
                arr = wKindIDArr.split(",");
            }
            if (arr.indexOf(wKindID + "") != -1) {//最近
                ske = "zj_ske_json"
                json = "zj_tex_json"
                tex = "zj_tex"
                Armature = "zj"
            } else if (newGame.indexOf(wKindID) != -1) {
                ske = "new_ske_json"
                json = "new_tex_json"
                tex = "new_tex"
                Armature = "new"
            } else {
                ske = "caid_ske_json"
                json = "caid_tex_json"
                tex = "caid_tex"
                Armature = "caid"
            }

            const factory2 = dragonBones.EgretFactory.factory;
            factory2.parseDragonBonesData(RES.getRes(ske));
            factory2.parseTextureAtlasData(RES.getRes(json), RES.getRes(tex));
            const armatureDisplay2 = factory.buildArmatureDisplay(Armature);
            armatureDisplay2.animation.play();
            armatureDisplay2.x = 230
            armatureDisplay2.y = 100
            armatureDisplay2.alpha = 0;
            group.addChild(armatureDisplay2);
            egret.Tween.get(armatureDisplay2).to({ alpha: 1 }, 800).call(() => {
                egret.Tween.removeTweens(armatureDisplay2)
            })
            HallMediator.DragonBonesLIST.push(armatureDisplay2)
            group.name = gameType;
            group.visible = true;
            group.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onGame, this);
            //个别龙骨位置微调
            if (gameType == InstructionsEnum.GAME_TYPE_NAME.WJL) {
                armatureDisplay.x = 136
            }
            if (gameType == InstructionsEnum.GAME_TYPE_NAME.BREBG) {
                armatureDisplay.x = 135
            }
            if (gameType == InstructionsEnum.GAME_TYPE_NAME.HLSZ) {
                armatureDisplay.y = 265
            }
        }
        //点击游戏按钮
        private onGame(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            var gameType = event.currentTarget.name;
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_ROOM_LIST, gameType)
        }
        //从游戏中退出
        private exitGame() {
            //清除当前正在玩的房间ID记录，避免切换前后台时再次重连该房间
            InstructionsEnum.ID_GAME = "";
            if (InstructionsEnum.SOUND_GAME != InstructionsEnum.GAME_SOUND_NAME.HALL) {
                SoundManage.stopYinYue();
                InstructionsEnum.SOUND_GAME = InstructionsEnum.GAME_SOUND_NAME.HALL
                SoundManage.startYinYueLoad();
            }
            //将滚动公告转移到当前面板
            EffectUtils.moveNoticeToPanel(this.panel.noticeGroup)
            //龙骨动画恢复运动
            for (let i = 0; i < HallMediator.DragonBonesLIST.length; i++) {
                if (HallMediator.DragonBonesLIST[i] && HallMediator.DragonBonesLIST[i].parent) {
                    HallMediator.DragonBonesLIST[i].animation.play()
                }
            }
        }
        //进入游戏
        private joinGame() {
            //龙骨动画暂停
            for (let i = 0; i < HallMediator.DragonBonesLIST.length; i++) {
                if (HallMediator.DragonBonesLIST[i] && HallMediator.DragonBonesLIST[i].parent) {
                    HallMediator.DragonBonesLIST[i].animation.stop()
                }
            }
        }
        //打开头像设置
        private userIconClick(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            EffectUtils.playDim(event.currentTarget)
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_SPECIA_MODIFY)
        }
        //复制ID
        private copyIDClick(event: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            copyText(GameVO.getVo().dwUserID + "")
            EffectUtils.textFadeAway("复制成功")
        }
        //打开设置页面
        private onSettingBtnClick(event: egret.TouchEvent): void {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_SETTING);
        }
        //打开充值
        private onAddMoneyBtnClick(event: egret.TouchEvent): void {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_ADD_MONEY);
        }
        //打开排行榜
        private onOpenRankingBtnClick(event: egret.TouchEvent): void {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_RANKING);
        }
        //打开保险箱
        private onOpenSafeBoxBtnClick(event: egret.TouchEvent): void {
            SoundManage.startAnniuBtnLoad();
            let objc = {
                "dwUserID": GameVO.getVo().dwUserID,
                "szPassword": new utils.MD5().hex_md5(GameVO.getVo().szPassword)
            }
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.HALL, RegDataGame.DBR_GP_QueryInsureInfo, objc, true);
        }
        //打开活动
        private huoDongClick() {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_ACTIVITY_CENTER)
        }
        //打开客服
        private kefuClick() {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_KEFU)
        }
        //打开邮箱
        private mailClick() {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_MAIL)
        }
        //打开代理
        private proxyClick() {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_PROXY)
        }
        //打开提现
        private TiXianClick() {
            SoundManage.startAnniuBtnLoad();
            var time = Math.floor(Global.getCurrTimeLong() / 1000)
            var signature = Global.getSynLoginKey(time)
            signature = signature.toUpperCase()
            var request = new egret.HttpRequest();
            request.responseType = egret.HttpResponseType.TEXT;
            request.open(InstructionsEnum.IP_API + "/GameWebApplication/Api/WithdrawSetting.ashx?userid=" + GameVO.getVo().dwUserID + "&time=" + time + "&signature=" + signature, egret.HttpMethod.POST);
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.addEventListener(egret.Event.COMPLETE, (event: egret.Event) => {
                try {
                    var request = <egret.HttpRequest>event.currentTarget;
                    var obj = JSON.parse(request.response)
                    if (obj.code == 0) {
                        if (obj.withdraw_status == 1) {
                            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIXIAN)
                        } else {
                            this.panel.tixian.visible = false;
                            Global.tipShow("抱歉，兑换功能已暂时关闭！")
                        }
                    } else {
                        Global.tipShow(obj["msg"])
                    }
                } catch (err) {
                    EffectUtils.textFadeAway("网络错误，请稍后重试！")
                }
            }, this);
            request.send();
        }
    }
}